package com.wn55.hrms.mapper;

import com.wn55.hrms.entity.RecruitChannel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RecruitChannelMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(RecruitChannel record);

    RecruitChannel selectByPrimaryKey(Integer id);

    List<RecruitChannel> selectAll();

    int updateByPrimaryKey(RecruitChannel record);


    /**
     * 根据条件查询渠道
     * @param channelName
     * @param channelType
     * @return
     */
    List<RecruitChannel> selectChannelByConds(@Param("channelName") String channelName, @Param("channelType") String channelType);

    /**
     * 添加渠道
     * @param recruitChannel
     */
    @Insert(value= "insert into recruit_channel (channel_id, channel_name, channel_type, channel_status, create_name, insert_time,update_name, update_time) " +
            "values(#{channelId},#{channelName},#{channelType},#{channelStatus},#{createName},#{insertTime},#{updateName},#{updateTime})")
    @Options(useGeneratedKeys = true,keyProperty ="id",keyColumn = "id")
    void insertChannel(RecruitChannel recruitChannel);

    /**
     * 修改渠道
     * @param recruitChannel
     */
    @Update("update recruit_channel set channel_id=#{channelId},channel_name=#{channelName},channel_type=#{channelType},channel_status=#{channelStatus}," +
            "create_name=#{createName},insert_time=#{insertTime},update_name=#{updateName},update_time=#{updateTime} where id = #{id}")
    void updateChannel(RecruitChannel recruitChannel);
}